<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
<script type="text/javascript">
	
	// call(this的指向，参数1，参数2)  
	// apply(this的指向，[参数1，参数2])  
	// bind(this的指向，参数1，参数2) 需要手动调用一下() 改变this指向
	let obj = {
		name:'张三',
		age:17,
		fn:function(love){
			console.log(this.name + 'love' + love, this.age)
		}
	}
	let obj2 = {
		name:'李四',
		age:66
	}

	obj.fn('cat') //张三lovecat 17
	//this的指向变成了obj2
	obj.fn.call(obj2,'dog') //李四lovedog 66
	obj.fn.apply(obj2,['apple'])//李四loveapple 66
	obj.fn.bind(obj2,'pear')() //李四lovepear 66


	//
	function Animal(name) {
		this.name = name
		this.showName = function() {
			console.log(this.name)
		}
	}
	Animal.prototype.getName  = function() {
		console.log('dog')
	} 
	function Dog(name) {
		Animal.call(this,name)
	}

	let dog = new Dog('VIP Dog')
	dog.showName() //VIP Dog
	// 原型上的不能继承
	// dog.showName() 报错
</script>
</body>
</html>